package com.ctshk.rpc.order.goods.mapper;

import com.ctshk.rpc.order.goods.base.CustomBaseMapper;
import com.ctshk.rpc.order.goods.entity.ShoppingCommoditySpecificationsAttribute;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商城商品规格属性表 Mapper 接口
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-13
 */
public interface ShoppingCommoditySpecificationsAttributeMapper extends CustomBaseMapper<ShoppingCommoditySpecificationsAttribute> {
	@Select({
			"<script>",
			"SELECT",
			"t.id,t.specifications_name_id,t.specifications_id,t.attribute_name,t.gmt_create,t.create_id,t.gmt_modified,t.modified_id,t.is_deleted  ",
			"FROM `ctshk-goods`.t_shopping_commodity_specifications_attribute t ",
			"WHERE t.is_deleted = 0 ",
			"<if test='specificationsNameId != null'> AND t.specifications_name_id = #{specificationsNameId}</if> ",
			"<if test='specificationsIds != null and specificationsIds.size !=0'>",
			"AND t.specifications_id IN ",
			"<foreach collection='specificationsIds' item='id' open='(' separator=',' close=')'>",
			"#{id}",
			"</foreach>",
			"</if>",
			"</script>"
	})
	List<ShoppingCommoditySpecificationsAttribute> findSpecificationsAttributeByNameId(
			@Param("specificationsNameId")Long specificationsNameId, @Param("specificationsIds")List<Long> specificationsIds);
}
